﻿namespace Wips.Domain.Models
{
    /// <summary>
    /// 服务器授权相关
    /// </summary>
    [SugarTable("agent_server_permission")]
    public class AgentServerPermission : ValueObjectBase
    {
        /// <summary>
        /// 权限ID
        /// </summary>
        /// <value></value>
        public string? AgentServerId { get; set; }

        /// <summary>
        /// 权限
        /// </summary>
        /// <value></value>
        [Navigate(NavigateType.ManyToOne, nameof(AgentServerId))]
        public AgentServer? AgentServer { get; set; }


        /// <summary>
        /// 权限ID
        /// </summary>
        /// <value></value>
        public string? AgentServerConfigId { get; set; }

        /// <summary>
        /// 权限
        /// </summary>
        /// <value></value>
        [Navigate(NavigateType.ManyToOne, nameof(AgentServerConfigId))]
        public AgentServerConfig? AgentServerConfig { get; set; }


        /// <summary>
        /// 菜单ID
        /// </summary>
        /// <value></value>
        public string UserId { get; set; } = "";

        /// <summary>
        /// 设置服务器授权
        /// </summary>
        /// <param name="agentServerId"></param>
        /// <param name="userId"></param>
        public void SetAgentServerAuth(string agentServerId, string userId)
        {
            AgentServerId = agentServerId;
            UserId = userId;
        }


        /// <summary>
        ///  设置服务器的服务授权
        /// </summary>
        /// <param name="agentServerConfigId"></param>
        /// <param name="userId"></param>
        public void SetAgentServerConfigAuth(string agentServerConfigId, string userId)
        {
            AgentServerConfigId = agentServerConfigId;
            UserId = userId;
        }


    }
}
